import {
  getUserInfo,
  getbankcards,
  luckyInfo
} from '../service/index'
import {
  SAVE_BANK_CARDS,
  SAVE_USER_INFO,
  USER_LOGIN,
  SAVE_LUCKY_PRIZES
} from './mutation-types.js'

export default {
  async getUserInfo ({commit, state}) {
    try {
      let resp = await getUserInfo()
      commit(SAVE_USER_INFO, resp.data.data)
      commit(USER_LOGIN)
    } catch (error) {
      console.log(error)
    }
  },
  async getBankCards ({commit, state}) {
    try {
      let resp = await getbankcards()
      commit(SAVE_BANK_CARDS, resp.data.data)
    } catch (error) {
      console.log(error)
    }
  },
  async getPrizes({commit, state}) {
    try {
      let resp = await luckyInfo()
      commit(SAVE_LUCKY_PRIZES, resp.data)
    } catch (error) {
      console.log(error)
    }
  }
}
